<?php
namespace app\index\model;
use think\Model as UserModel;
use traits\model\SoftDelete;
use think\Db;
use think\Validate;

class Menu extends UserModel
{
	
	public function menu()
	{
		return $this->where('category=0')->select();
		
	}
	public function selemenu($data)
	{
		//dump(Db::table('mall_user')->fecthSql()->insert($data));
		
		return $this->where('category','=',$data)->select();
		
	}
	public function getProducts()
	{
		return $this->table('mall_product')->select();
		
	}
	public function getProduct($pid)
	{
		return $this->table('mall_product')->where("pid=$pid")->select();
	}
	public function getPictures()
	{
		return $this->table('mall_image image,mall_product product')->where('image.pid =product.pid ')->limit(9)->select();
	}
	public function getContent($pid)
	{
		return $this->table('mall_comment')->where("pid=$pid")->select();
	}
	public function check($username)
	{
		$result = Db::table('mall_user')->where('username','=',$username)->find();
		if($result){
			return true;
		}else{
			return '此昵称已存在';
		}

	}
	public function getids($username)
	{
		return $this->table('mall_user')->where('username','=',$username)->select();
	}
	public function add($data)
	{
		return $this->table('mall_collection')->insert($data);
		/*$this->getLastSql();*/
	}
}